<?php
    header('Content-Type:application/json,charset=utf8');
    @$uname = $_REQUEST['uname'] or die('{"code":3,"msg":"uname unquired"}');
    @$upwd = $_REQUEST['upwd'] or die('{"code":4,"msg":"upwd unquired"}');
    require('init.php');
    $sql = "select * from register where uname='$uname' and  upwd='$upwd'";
    $result = mysqli_query($conn,$sql);

    $row = mysqli_fetch_assoc($result);

    if($row===null){
        $output=['code'=>2,'msg'=>'用户名或密码错误'];
    }else {
        $output= ['code'=>1,'uname'=>$uname,'uid'=>$row['uid']];
    }
    echo json_encode($output);